<template>
  <!-- 预警模型 -->
  <div style="padding: 20px">
    <el-form inline :model="form" ref="form" label-width="100px" size="mini">
      <el-form-item label="查询日期">
        <el-col :span="11">
          <el-form-item prop="beginDate">
            <el-date-picker
              type="date"
              placeholder="选择开始日期"
              v-model="form.beginDate"
              style="width: 100%"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-form-item prop="endDate">
            <el-date-picker
              placeholder="选择结束时间"
              v-model="form.endDate"
              style="width: 100%"
              type="date"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="查询分值">
        <el-col :span="11">
          <el-form-item prop="min">
            <el-input placeholder="请输入最小值" v-model="form.min"></el-input>
          </el-form-item>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-form-item prop="max">
            <el-input placeholder="请输入最大值" v-model="form.max"></el-input>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-button
        type="primary"
        size="mini"
        icon="el-icon-search"
        @click="handleQuery"
        >搜索</el-button
      >
      <el-button size="mini" icon="el-icon-refresh" @click="resetForm('form')"
        >重置</el-button
      >
      <el-button
        size="mini"
        icon="el-icon-tickets"
        type="success"
        @click="report"
        >生成报告</el-button
      >
    </el-form>
    <el-table :header-cell-style="thaderBack" :data="tableData">
      <el-table-column label="序号" width="80" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="riskModelName"
        label="模型名称"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column prop="totalScore" label="分值" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="level" label="等级名称" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="createDate" label="评分时间" show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        label="操作"
        align="left"
        class-name="small-padding fixed-width"
        width="120"
      >
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="handleUpdate(scope.row)"
            ><i class="el-icon-document"></i>查看</el-button
          >
          <el-button type="text" size="mini" @click="exportList(scope.row)"
            ><i class="el-icon-top"></i>导出</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="config.page"
      :page-size="config.limit"
      layout="total,prev, pager, next, jumper"
      :total="total"
      class="pager"
    ></el-pagination>
    <el-dialog width="50%" title="详情" :visible.sync="isShow">
      <el-table :data="reportList" style="width: 100%">
        <el-table-column label="序号" width="80" align="center">
          <template slot-scope="scope">
            <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="一级指标">
          <el-table-column
            prop="primaryIndicatorsName"
            label="指标名称"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="primaryIndicatorsWeight"
            label="权重值"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table-column>
        <el-table-column label="二级指标">
          <el-table-column
            prop="secondaryIndicatorsName"
            label="二级指标"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="secondaryIndicatorsWeight"
            label="单位权重值"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="secondaryIndicatorsFinalWeight"
            label="最终权重值"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table-column>
        <el-table-column label="分值">
          <el-table-column
            prop="secondaryIndicatorsRubric"
            label="分值"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="secondaryIndicatorsScore"
            label="加权分值"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import { communal } from '@/api/common.js'
export default {
  mixins: [communal],
  data() {
    return {
      url: '/riskWarn/totalScoreInfo/list',
      form: {
        beginDate: null,
        endDate: null,
        min: null,
        max: null
      },
      reportList: []
    }
  },
  methods: {
    report() {
      this.$http.get('/riskWarn/totalScoreInfo/configureTasks').then(() => {
        this.getList()
      })
    },
    handleUpdate(row) {
      this.$http
        .get(
          '/riskWarn/totalScoreInfo/findByTotalScoreId?totalScoreId=' +
            row.totalScoreId
        )
        .then(res => {
          if (res.code === 200) {
            this.reportList = res.data
            this.statusType = 'edit'
            this.isShow = true
          }
        })
    },
    exportList(row) {
      window.location.href =
        process.env.VUE_APP_BASE_API +
        'riskWarn/totalScoreInfo/down?totalScoreId=' +
        row.totalScoreId
    }
  }
}
</script>

<style lang="scss" scoped>
.line {
  text-align: center;
}
</style>
